using UnityEngine;

namespace Math
{
    public struct IVector2
    {
        public static IVector2 zero { get { return new IVector2(0, 0); } }

        public int x;
        public int y;

        public IVector2(int x, int y)
        {
            this.x = x;
            this.y = y;
        }

        public IVector2(IVector2 v)
        {
            this.x = v.x;
            this.y = v.y;
        }

        public override bool Equals(System.Object obj)
        {
            return (obj is IVector2) && (this==(IVector2)obj);
        }

        public static bool operator==(IVector2 a, IVector2 b)
        {
            return (a.x==b.x) && (a.y==b.y);
        }

        public static bool operator!=(IVector2 a, IVector2 b)
        {
            return !(a==b);
        }

        public static IVector2 operator+(IVector2 a, IVector2 b)
        {
            return new IVector2(a.x+b.x, a.y+b.y);
        }

        public static IVector2 operator-(IVector2 a, IVector2 b)
        {
            return new IVector2(a.x-b.x, a.y-b.y);
        }

        public static IVector2 operator+(IVector2 a, int value)
        {
            return new IVector2(a.x+value, a.y+value);
        }

        public override int GetHashCode()
        {
            return x.GetHashCode()^y.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("({0}, {1})", x, y);
        }
    }
}